package service

import (
	erp "ez/apps/erp/document"
	"gitee.com/dreamwood/ez-go/ez"
)

func BuyOrderFillNumAndMoney(orderId int64) {
	crudBuyOrder := erp.NewBuyOrderCrud()
	buyOrder, e := crudBuyOrder.FindId(orderId)
	if ez.Try(e) {
		return
	}
	buyOrder.LoadProduct()
	num := 0.0
	money := 0.0
	for _, product := range buyOrder.Product {
		num += product.Num
		money += product.Money
	}
	buyOrder.Num = num
	buyOrder.Money = money
	_ = buyOrder.Save()

}
